//Accepted
#include <cstdio>
#include <cstring>

int n, x[1000001], y, i, j, a, b, sum, t, m;

int main(){
	//freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);
	while(scanf("%d", &y)==1){
		scanf("%d", &n);
		memset(x,0,sizeof(x));
		for(i=0;i<n;++i){
			scanf("%d", &j);
			x[j]++;
			m=j;
		}
		sum=a=b=0;
		
		//for(i=0;i<=m;++i)printf("%2d ", i);printf("\n");for(i=0;i<=m;++i)printf("%2d ", x[i]);printf("\n");
		
		for(i=0;i<y;++i){
			
			if(!a && x[i])a=i;
			if(x[i]){
				b=i;
				sum+=x[i];
			}
			//printf("%d:%d %d %d %d\n", i, x[i], sum, a, b);
		}
		//printf("\n");
		t=sum;
		for(;i<=m;++i){
			t+=x[i];
			t-=x[i-y];
			if(t>sum){
				sum=t;
				b=i;
				if(a<i){
					for(j=i-y+1;!x[j];++j);
					a=j;
					}
			}
			//printf("(%d,%d]:%d %d %d %d\n", i-y,i, x[i], sum, a, b);
		}
		printf("%d %d %d\n", sum, a, b);
		
	}
	
	return 0;
}
